package sjtu.pirate.report.frame;

import java.io.IOException;
import java.util.List;

import sjtu.pirate.analyzer.PirateAnalyzer;
import sjtu.pirate.format.FormResult;
import sjtu.pirate.report.Report;
import sjtu.pirate.report.ReportTemplate;
import sjtu.pirate.report.simple.FormsTemplate;
import biz.source_code.miniTemplator.MiniTemplator.TemplateSyntaxException;
/**
 * @author wilbur.ma@qq.com
 * @date 2011.06.01
 */
public class FrameReport extends Report {
	public FrameReport(String templatesDir, String targetDir, PirateAnalyzer analyzer) 
			throws TemplateSyntaxException, IOException 
	{
		super(
				templatesDir, 
				targetDir, 
				new String[][]{
						{"simple", "js"},
						{"simple", "img"},
						{"simple", "style"},
						{"frame", "style"},
						{"frame", "index.html"}
				}, 
				analyzer
		);
	}

	@Override
	public void initReportTemplates(PirateAnalyzer analyzer)
			throws TemplateSyntaxException, IOException {
		ReportTemplate formIndex = new FormIndexTemplate(templatesDir + "/frame/formIndex.html", targetDir, analyzer);
		templates.add(formIndex);
		OverviewTemplate overview = new OverviewTemplate(templatesDir + "/frame/overview.html", targetDir, analyzer);
		templates.add(overview);
		for (String host : analyzer.getResults().keySet()) {
			for (List<FormResult> list: analyzer.getResults().get(host).values()) {
				FormsTemplate ft = new FormsTemplate(templatesDir + "/simple/forms.html", targetDir, analyzer, list);
				templates.add(ft);
			}
		}
	}
}
